<?php

namespace App\Models\Order;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Order
 * @package App\Models\Order
 * @version January 16, 2018, 12:09 pm CST
 *
 * @property string oprator_name
 * @property string pay_channel
 * @property string order_id
 * @property string pay_type
 * @property decimal pay_amount
 * @property string pay_seq
 * @property tinyInteger pay_state
 * @property string pay_desc
 * @property string user_name
 * @property string target_id
 * @property string card_no
 * @property string extend
 * @property tinyInteger recharge_type
 * @property string recharge_account
 */
class Order extends Model
{
    use SoftDeletes;

    /**
     * 此模型的连接名称。
     *
     * @var string
     */
    protected $connection = 'interface';

    public $table = 'orders';

    protected $dates = ['deleted_at'];

    public $fillable = [
        'oprator_name',
        'sp_name',
        'order_no',
        'amount',
        'pay_state',
        'is_support_reconciliation',
        'vasseti_name',
        'price_type',
        'mac',
        'card_id',
        'content_id',
        'result',
        'description',
        'service_code',
        'service_type',
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'oprator_name'              => 'string',
        'sp_name'                   => 'string',
        'order_no'                  => 'string',
        'amount'                    => 'string',
        'is_support_reconciliation' => 'string',
        'vasseti_name'              => 'string',
        'mac'                       => 'string',
        'card_id'                   => 'string',
        'content_id'                => 'string',
        'result'                    => 'string',
        'description'               => 'string',
        'service_code'              => 'integer',
        'service_type'              => 'integer',
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'oprator_name' => 'required|max:25',
        'pay_channel'  => 'required|max:25',
        'order_id'     => 'required|unique:orders,order_id|max:50',
        'pay_type'     => 'required',
        'pay_state'    => 'required|numeric|between:0,99999999.99',
        'pay_seq'      => 'max:50',
        'pay_state'    => 'required',
        'user_name'    => 'max:50',
        'target_id'    => 'max:50',
        'card_no'      => 'max:50',
        'extend'       => 'max:50',
    ];

}
